package goo

import (
	"fmt"
	"log"
	"net/http"
)

//goo app start
func AppStart(config ConfigInterface, port int) {

	config.ConfigConstant(ConfigInstance())
	config.ConfigRoute(RoutesInstance())
	RoutesInstance().sort()
	config.AfterStart()

	SessionMangerInstance().Init(&SessionMemoryProvider{sessions: make(map[string]*SessionMemory)}, "GOSESSIONID", 3600)

	http.HandleFunc("/", handle)
	fmt.Printf("Goo server start on %d.\n", port)
	err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
	if err != nil {
		log.Fatal("Goo server start failed: ", err)
	}

}
